package com.njtoyo.taxi.admin.rest.controller.local_service.merchant;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njtoyo.taxi.admin.aop.PermissionScope;
import com.njtoyo.taxi.admin.rest.presenter.local_service.merchant.LifeMerchantExaminePresenter;
import com.njtoyo.taxi.admin.rest.wrapper.local_service.merchant.examine.ExamineWrapper;
import com.njtoyo.taxi.admin.rest.wrapper.local_service.merchant.examine.LifeMerchantExamineWrapper;
import com.njtoyo.taxi.admin.service.local_service.merchant.MerchantExamineService;
import com.taxi.entity.common.RestResult;
import com.njtoyo.taxi.entity.backend.AdminUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.validation.Valid;

@RestController
@Api(value = "商户审核管理", tags = "商户审核管理")
@RequestMapping("local-service/merchant/examine")
public class MerchantExamineController {

    @Autowired
    private MerchantExamineService lifeMerchantExamineService;

    @GetMapping("")
    @ApiOperation(value = "商户审核列表", notes = "商户审核列表,权限：")
        //    @PermissionScope(names = {""})
    RestResult<Page<LifeMerchantExaminePresenter>> getPage(@ApiIgnore @ModelAttribute("admin") AdminUser adminUser,
                                                           @Valid LifeMerchantExamineWrapper wrapper) {
        return lifeMerchantExamineService.getExaminePage(adminUser, wrapper);
    }

    @GetMapping("/{id}")
    @ApiOperation(value = "商户审核详情", notes = "商户审核详情")
        //    @PermissionScope(names = {""})
    RestResult<LifeMerchantExaminePresenter> details(@PathVariable("id") Long id) {
        return lifeMerchantExamineService.details(id);
    }


    @PatchMapping("/{id}")
    @ApiOperation(value = "审核商户", notes = "life_merchant_update")
    @PermissionScope(names = {"life_merchant_update"})
    RestResult examine(@PathVariable("id") Long id,
                       @Valid @RequestBody ExamineWrapper wrapper) {
        return lifeMerchantExamineService.examine(id, wrapper);
    }

}